<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>观看视频</title>
    <link href="//vjs.zencdn.net/5.19/video-js.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/css/reset.css">
    <link rel="stylesheet" href="/css/normalize.css">
    <style>
        h1 {
            text-align: center;
            font-size: 20px;
        }

        .video-js {
            width: 100%;
            height: 300px;
        }
    </style>
</head>

<body>
    <h1>观看视频</h1>
    <div>
        <video id="my-player" class="video-js" autoplay width="100%" controls playsinline>
            <source src="" type="video/mp4">
        </video>
    </div>
    <script type="application/javascript" src="http://file.laoshi123.com/web/extension/js/jquery-2.1.1.min.js"></script>
    <script src="https://sfile.tl100.com/js/libs/axios.min.js"></script>
    <script src="//vjs.zencdn.net/5.19/video.min.js"></script>
    <script>
        $(document).ready(function () {
            const api = axios.create({
                baseURL: 'https://api.tl100.com/exam_signup',
                withCredentials: true,
                timeout: 5000
            });

            var video_id = '<%=video_id%>';

            localStorage.setItem('video_id', video_id);
            
            if(localStorage.getItem('token')){
                api.post('api/sign_up_xiaofeng/getVideo', {
                    video_id: video_id,
                    token: localStorage.getItem('token')
                })
                    .then(res => {
                        if(res.data.res_code == 1){
                            var myPlayer = videojs('my-player');
                            myPlayer.src(res.data.msg);
                        } else if (res.data.res_code == -995){
                            location.replace('/resource/login')
                        } else {
                          alert(res.data.msg);
                        }
                    })
                    .catch(error => {

                    })
            } else {
                location.replace('/resource/login')
            }
        })
    </script>
</body>

</html>